#include <stdio.h>

int run(int n){
	int total = 0;
	for(int unit = 1;;unit++){
		total = unit*n + 1;
		bool flag = true;
		for(int ite = 1;ite < n;ite++){
			if(total%(n-1) != 0){
				flag = false;
				break;
			}
			total = (total/(n-1))*n + 1;
		}
		if(flag == true)break;
	}
	return total;
}

int main(){
	int n;
	while(scanf("%d",&n),n > 0){
		printf("%d\n",run(n));
	}
	return 0;	
}